import java.util.TreeMap;
import java.util.function.BiConsumer;

public class Test02 {
    public static void main(String[] args) {
        String s="abcabcabcjd";
        TreeMap<Character,Integer> tm=new TreeMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c=s.charAt(i);
            if(tm.containsKey(c)){
                int count=tm.get(c);
                count++;
                tm.put(c,count);
            }
            else{
                tm.put(c,1);
            }
            StringBuilder sb=new StringBuilder();
            tm.forEach(new BiConsumer<Character,Integer>(){
                @Override
                public void accept(Character key,Integer value){
                    sb.append(key).append("[").append(value).append("]");
                }
            });
        }
        System.out.println(s);
    }
}
